//package com.fc.hkx.api;
//
//import com.fc.hkx.dto.LoginRequest;
//import com.fc.hkx.service.ITokenService;
//import com.fc.hkx.service.IUserService;
//import com.fc.hkx.utils.R;
//import com.fc.hkx.utils.annotation.IgnoreAuth;
//import com.fc.hkx.utils.validator.Assert;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.util.Map;
//
///**
// * API登录授权
// *
// * @author Rocky
// */
//@RestController
//@RequestMapping("/api")
//@Api("登录接口")
//public class ApiLoginController {
//    private final IUserService IUserService;
//    private final ITokenService ITokenService;
//
//    @Autowired
//    public ApiLoginController(IUserService IUserService, ITokenService ITokenService) {
//        this.IUserService = IUserService;
//        this.ITokenService = ITokenService;
//    }
//
//    /**
//     * 登录
//     */
//    @IgnoreAuth
//    @PostMapping("login")
//    @ApiOperation(value = "登录", notes = "登录说明")
//    @ApiImplicitParams({
//            @ApiImplicitParam(paramType = "query", dataType = "string", name = "mobile", value = "手机号", required = true),
//            @ApiImplicitParam(paramType = "query", dataType = "string", name = "password", value = "密码", required = true)
//    })
//    public R login(String mobile, String password) {
//        Assert.isBlank(mobile, "手机号不能为空");
//        Assert.isBlank(password, "密码不能为空");
//
//        //用户登录
//        long userId = IUserService.login(mobile, password);
//
//        //生成token
//        Map<String, Object> map = ITokenService.createToken(userId);
//
//        return R.ok(map);
//    }
//
//    @IgnoreAuth
//    @PostMapping("login/json")
//    public R loginJson(@RequestBody LoginRequest loginBean) {
//        Assert.isBlank(loginBean.getMobile(), "手机号不能为空");
//        Assert.isBlank(loginBean.getPassword(), "密码不能为空");
//
//        //用户登录
//        long userId = IUserService.login(loginBean.getMobile(), loginBean.getPassword());
//
//        //生成token
//        Map<String, Object> map = ITokenService.createToken(userId);
//
//        return R.ok(map);
//    }
//
//}
